<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>A4YY的推荐资源</title>
    <link href="${contextPath}/resource/css/a4yy/index.css" rel="stylesheet" type="text/css"/>
    <#include "/common/common.ftl">
</head>
<body>
    <div class="tool-bar">
        <Button id="searchBtn">搜索</Button>
        <input type="text" class="text-field"/>
    </div>
    <div class="content">
    </div>
</body>
<script>
    $(function(){

        $("#searchBtn").click(function(){
            var key = $(this).next().val();
            location.href=basePath+"/a4yy/to/search?param="+key;
        });
        $(document).on("click","div[class=content]>div",function(){
            var url=$(this).data("linked");
            location.href=basePath+"/a4yy/to/detail?param="+url;
        });

        var reg = new RegExp("<.+?>","g");
        loadNewJs("http://aaqqy.com/tree_items.js",function(){
            var list=[];
            for(var i in TREE_ITEMS[0]){
                var info = TREE_ITEMS[0][i];
                if(info.constructor===Array){
                    var name=info[0].toString().replace(reg,"");
                    var url=info[1];
                    list.push({name:name,url:url});
                }
            }
            initList(list);
        })
    })

    function initList(list){
        var content = $("div[class=content]");
        for(var i in list){
            var info = list[i];
            var div=$("<div></div>").appendTo(content);
            div.data("linked",info.url);
            $("<div class='img'></div>").appendTo(div);
            var infoContent = $("<div class='info'></div>").appendTo(div);
            var ul = $("<ul></ul>").appendTo(infoContent);
            var li=$("<li></li>").appendTo(ul);
            li.text(info.name);
            li=$("<li></li>").appendTo(ul);
            li.text("无");
        }
    }
</script>
</html>